import 'package:flutter/material.dart';
import 'package:myapp/util/colors_utils.dart';

class PersonPage extends StatefulWidget {
  const PersonPage({Key key}) : super(key: key);

  @override
  _PersonPageState createState() => _PersonPageState();
}

class _PersonPageState extends State<PersonPage>
    with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Center(
            child: Text("个人中心",
                style: TextStyle(
                  color: ColorUtils.color_text_1,
                  fontSize: 15,
                ))),
      ),
      body: Column(
        children: [
          Container(
            margin: EdgeInsets.only(top: 8),
            padding: EdgeInsets.all(16),
            child: Row(
              children: [
                Container(
                  child: Icon(
                    Icons.person,
                    size: 50,
                    color: ColorUtils.color_text_2,
                  ),
                  decoration: BoxDecoration(
                      color: ColorUtils.color_bg_3, shape: BoxShape.circle),
                  padding: EdgeInsets.all(5),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 16),
                  child: Text(
                    "登录/注册",
                    textAlign: TextAlign.center,
                    style:
                        TextStyle(color: ColorUtils.color_text_1, fontSize: 15),
                  ),
                ),
                Expanded(
                  child: SizedBox.shrink(),
                  flex: 1,
                ),
                Icon(
                  Icons.arrow_right,
                  size: 25,
                )
              ],
            ),
            color: ColorUtils.color_bg_1,
          ),
          _getItemWidget(Icons.score, "我的积分", 8),
          _getItemWidget(Icons.sports_score, "积分排行", 1),
          _getItemWidget(Icons.share, "我的分享", 8),
          _getItemWidget(Icons.collections, "我的收藏", 1),
          _getItemWidget(Icons.history, "浏览历史", 1),
          _getItemWidget(Icons.settings, "系统设置", 1),


        ],
      ),
    );
  }

  _getItemWidget(IconData iconData, String title, double top) {
    return Container(
        margin: EdgeInsets.only(top: top),
        padding: EdgeInsets.only(left: 16, top: 10, bottom: 10),
        color: ColorUtils.color_bg_1,
        child: Row(
          children: [
            Icon(
              iconData,
              size: 20,
              color: ColorUtils.color_text_1,
            ),
            Padding(
              padding: EdgeInsets.only(left: 14),
              child: Text(
                title,
                style: TextStyle(color: ColorUtils.color_text_1, fontSize: 13),
              ),
            )
          ],
        ));
  }

  @override
  bool get wantKeepAlive => true;
}
